(function () {
    const slideshow=document.getElementById('slideshow');
    const left=document.getElementById('jiantou-left ')
    const right=document.getElementById('jiantou-right')
    const banner=document.getElementById('banner')
    let dot=document.getElementById('dot')
    let item=dot.getElementsByTagName('li')
   let first= slideshow.firstElementChild.cloneNode(true);
   slideshow.appendChild(first);
    let idx=0;
    let lock=true
    right.addEventListener('click',gu,false);
   function gu(){
        if(!lock)return
        lock=false;
        slideshow.style.transition = 'all .5s ease 0s'
        idx++;
        if(idx>4){
            setTimeout(()=>{
                slideshow.style.transition ='none'
                idx=0;
                slideshow.style.transform='translateX('+-16.66*idx+'%)';
            },500)
        }
        slideshow.style.transform='translateX('+-16.66*idx+'%)';
        setTimeout(function () {
            lock = true;
        }, 500)
        dot_1()
       
    }
   left.addEventListener('click',()=>{
        if (!lock) return;
        lock = false;
        slideshow.style.transition='all .5s ease 0s'
        if(idx==0){
            slideshow.style.transition ='none'
            slideshow.style.transform='translateX('+-16.66*5+'%)';
            idx=4;
            setTimeout(function(){
                slideshow.style.transition='all .5s ease 0s'
                slideshow.style.transform='translateX('+-16.66*idx+'%)';
            },0)
        }else{
            idx--;
            slideshow.style.transform='translateX('+-16.66*idx+'%)';
        }
        setTimeout(function () {
            lock = true;
        }, 500)
        dot_1();
   },false)     
    let settime=setInterval(gu,2000);
   banner.onmouseenter=()=>{
    clearTimeout(settime);
   }
   banner.onmouseleave=()=>{
    clearTimeout(settime);
    settime=setInterval(gu,2000);
   }
   function dot_1() {
    for (var i = 0; i < 5; i++) {
        if (i == idx%5) {
            item[i].className ='cur';
        } else {
            item[i].className = '';
        }
    }
}
    dot.onclick=(e)=>{
     var n= e.target.getAttribute('data-n');
     idx=n;
     slideshow.style.transform = 'translateX(' + -16.66 * idx + '%)';
     dot_1();
    }
})()